/**
 * 栈
 */
function Stack() {
    var elems = []
    return {
        push: e => elems.addLast(e),
        pop: () => elems.removeLast(),
        top: () => elems[elems.length() - 1]
    }
}

var stack = Stack()
stack.push(1)
stack.push(2)
stack.push(3)
println(stack.pop())
println(stack.pop())
stack.push(4)
stack.push(5)
println(stack.top())
println(stack.pop())
println(stack.top())
stack.pop()
println(stack.top())
println(stack.pop())
